<?php
/**
 * Logic
 *
 * Logic support.
 *
 * @author  Badrus Said <badrus.said@gmail.com>
 * @since   gop1.0
 */
final class gop_Logic extends gop_Base {
    public function execute(gop_Base $_caller = null) {
        if ($this->getReturn()) return;
        $this->setCaller($_caller);
        $_return = null;
        $G1 = (is_bool($this->L)) ? $this->L : $this->getContext()->getCallee($this->L)->execute($this);
        $G2 = (is_bool($this->R)) ? $this->R : $this->getContext()->getCallee($this->R)->execute($this);
        switch($this->Operator) {
            case "&&": $_return = $G1 && $G2; break;
            case "||": $_return = $G1 || $G2; break;
        }
        $this->setResult($_return);
        $this->chainExec();
    }
}
?>